﻿namespace TaskWaitDemo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var task = ThirdRowHubInspection();
                IntermediateCameraDetect();
                task.Wait();
            }
        }

        private static async Task ThirdRowHubInspection()
        {
            List<Task> tasks = new List<Task>();
            tasks.Add(Task.Run(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine($"第一个线程完成-{Thread.CurrentThread.ManagedThreadId.ToString("00")}");
            }));
            tasks.Add(Task.Run(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine($"第二个线程完成-{Thread.CurrentThread.ManagedThreadId.ToString("00")}");
            }));
            await Task.WhenAll(tasks);
            Console.WriteLine($"两侧相机检测完毕");
        }

        private static void IntermediateCameraDetect()
        {
            Thread.Sleep(1000);
            Console.WriteLine($"第三个线程完成-{Thread.CurrentThread.ManagedThreadId.ToString("00")}");
            Console.WriteLine($"中间相机检测完毕");
        }
    }
}
